home *** CD-ROM | disk | FTP | other *** search
/ Megarom / Megarom Macintosh CD Software (Quantum Leap)(1992).iso / UPDATERS / THINK C 5.0.1 Update Package / About THINK C 5.0.1 next >
Encoding:
Text File  |  1991-10-11  |  17.4 KB  |  470 lines  |  [TEXT/ttxt]

  1. ABOUT THINK C 5.0.1
  2. ==================
  3. Copyright © 1991 Symantec Corporation. All rights reserved.
  4. October 9, 1991
  5. Font: Geneva 12
  6.  
  7. INTRODUCTION
  8. =============
  9. THINK C 5.0.1 lets you debug programs on a Macintosh with a MC68040 and 
  10. corrects some bugs in THINK C 5.0.  
  11.  
  12. This document has five sections:
  13.  
  14.     •  UPDATING THINK C tells you how to run “THINK C => 5.0.1” to 
  15.         update your copy of THINK C.
  16.  
  17.     •  WHAT THIS UPDATE FIXES lists the most important bugs that 
  18.         this update fixes.
  19.  
  20.     •  LAST MINUTE CHANGES lists some last minute changes and 
  21.         corrections to the THINK C User Manual and Standard Libraries
  22.         Reference. This section contains much of the information in the 
  23.         READ ME file on your THINK C 5.0 disk, in addition to some more  
  24.         recent information. 
  25.  
  26.     •  TECH TIPS answers some common questions that people ask  
  27.         our Technical Support staff. When you have a problem with 
  28.         THINK C, use this section along with Appendix B, 
  29.         “Troubleshooting,” to try to find a solution. And when you 
  30.         port a program from THINK C 4.0 to THINK C 5.0, use this 
  31.         section along with Appendix A, “What’s New,” for some helpful 
  32.         hints.   
  33.  
  34.     •••••••••
  35.     IMPORTANT
  36.     •••••••••
  37.         Some copies of the Object-Oriented Programming Manual have 
  38.         a misprint: page 313 is a duplicate of page 321. To get a copy of
  39.         the correct 313, you need to use the THINK Class Library 1.1.1 
  40.         update.
  41.  
  42. UPDATING THINK C
  43. =================
  44. This update transforms your existing THINK C 5.0 application to THINK C 
  45. 5.0.1. You will run the patch program “THINK C => 5.0.1” and then replace
  46. your debugger.
  47.  
  48.     1. Make sure that you have your original THINK C application.
  49.         You won't need it for this update, but you should make
  50.         sure that you have a backup in case the update fails. Do not
  51.         patch your original master disk.
  52.  
  53.     2. Double-click on the patch program "THINK C => 5.0.1" to
  54.         launch it. Click on the Update THINK C button to continue.
  55.  
  56.     3. Find your existing copy of THINK C in your THINK C Folder.
  57.         Select it and click on the Patch button.
  58.  
  59.     4. If the patch was successful, you'll get a confirmation.
  60.     
  61.     5. Replace your THINK C 5.0 Debugger with the THINK C 5.0
  62.         Debugger included with the upgrade.
  63.     
  64.     6. Recompile all the files in your projects to make sure they
  65.         take advantage of the changes. To recompile a project, open 
  66.         it in THINK C, choose Remove Objects from the Project menu, 
  67.         and choose Bring Up To Date from the Project menu.
  68.  
  69. WHAT THIS UPDATE FIXES
  70. =======================
  71. THINK C 5.0.1 is a minor update to THINK C 5.0 that lets you debug programs on a Macintosh with the MC68040 and fixes some bugs. This section describes the most 
  72. significant bugs that THINK C 5.0.1 fixes. It contains these parts:
  73.  
  74. •  “The Environment” describes what’s fixed in the THINK C 
  75.     environment.
  76. •  “Optimizations” describes what’s fixed in THINK C’s global optimizer and
  77.      other optimizations.
  78. •  “Object-Oriented Programming Extensions” describes what’s fixed in 
  79.     THINK C’s object-oriented programming extensions.
  80. •  “Compiler and Linker” describes what else is fixed in THINK C‘s compiler 
  81.     and linker.
  82.  
  83. The Environment
  84. ---------------
  85. •  When you’re running System 7.0 in 32-bit addressing mode, these features
  86.     now work correctly:
  87.         √ The “Grep” option in the Find… dialog.
  88.         √ Using the Browser to look up a method or class definition.    
  89.         
  90. •  The Get Info… dialog doesn’t truncate the last character of the JUMP table
  91.     size.
  92.     
  93. Optimizations
  94. -------------
  95. •  The “Suppress redundant loads” option is more careful when choosing to
  96.     suppress a load.
  97.  
  98. •  The “CSE elimination” option is more careful when deciding
  99.     whether to eliminate common sub-expressions in switch expressions.
  100.     
  101. •  The “Induction variable elimination” option is more careful when 
  102.     deciding whether an expresion is an induction variable.
  103.     
  104. •  The “CSE elimination” and “Register coloring” options are more careful 
  105.     when optimizing statements with the operators && or ||.
  106.  
  107. Object-Oriented Programming Extensions
  108. -------------------------------------
  109. •  THINK C now flags as an error a static member function that references
  110.     a non-static member of a class without an object pointer.
  111.     
  112. •  Calling a virtual static method works correctly.
  113.  
  114. Compiler and Linker
  115. ------------------
  116. •  There is now a limit of 256 segments per project. THINK C 5.0 had a limit  
  117.     of 128 segments per project.
  118.     
  119. •  You do not get the incorrect error message “internal error: Bad ZREF,” if 
  120.     the linker encounters an error while building your program. 
  121.      
  122. •  If you use typedef to define a type as void and declare something with 
  123.     that type, you do not get the error message “illegal use of void”.
  124.     
  125. •  If there are several #define statements before a precompiled header, 
  126.     THINK C does not generate an internal compiler error. 
  127.  
  128. •  THINK C now correctly stores the size of array types declared in
  129.     precompiled headers. 
  130.  
  131. •  If a macro and a type have the same name, and you use the name to 
  132.     declare a variable, THINK C does not give you the incorrect error message 
  133.     “invalid declaration.”     
  134.  
  135. •  A multi-segment code resource, driver, or desk accessory built with 
  136.     THINK C works correctly if it is unlocked and moves in memory.
  137.     
  138. •  When assigning one struct to another, the code THINK C generates now
  139.     works correctly if the source struct is cached in an MC68040 data
  140.     register.
  141.  
  142. •  The FNEG.X instruction generates correct code when you use it with a 
  143.     single floating-point register argument. Previously, for example,   
  144.     “FNEG.X FP0” generated code for “FABS.X FP0”.
  145.  
  146.  
  147. LAST MINUTE CHANGES
  148. ====================
  149. This section lists some last minute changes and corrections to the THINK C 
  150. User Manual and Standard Libraries Reference. It contains much of the 
  151. information in the READ ME file on your THINK C 5.0 disk, in addition to some 
  152. more recent information.
  153.          
  154. Installing THINK C 5.0
  155. --------------------
  156. • On page 20, step 4 should refer you to Figure 2-2, not 2-1.
  157.  
  158. • On page 21, the folder is shown in Figure 2-3, not 2-1.
  159.  
  160. Tutorial: MiniEdit
  161. ----------------
  162. •  The first paragraph on page 49 tells you to click the wrong button. You
  163.     should click on the Done button, not the Cancel button.
  164.  
  165. •  On pages 55 and 56, the Set Project Type… dialog in Figures 4-14 and 
  166.     4-15 probably doesn’t match yours. The default value for the SIZE Flags
  167.     field is 0000, and not 0800. The project works correctly with either 
  168.     value.
  169.     
  170. •  On page 57,  the first sentence of the section “Using a Resource File” is
  171.     incorrect. You didn’t copy the MiniEdit Folder from disk THINK C 4. 
  172.     Instead you installed it with the self-extracting archive “THINK C 5.0 
  173.     Demos.sea,” according to the instructions in Chapter 2, “Installing 
  174.     THINK C 5.0.”
  175.     
  176. The Compiler
  177. -------------
  178. •  The THINK C compiler and optimizer use MultiFinder memory. If you get an
  179.     “Out of Memory“ error, quit your other running applications to increase 
  180.     the amount of MultiFinder memory available.
  181.  
  182. •  The optimizer can take a long time to optimize extremely large and 
  183.     complex functions (typically, more than 10 pages of dense code).
  184.  
  185. The Assembler
  186. --------------
  187. •  The note on page 270 needs some explanation. When you write a 
  188.     function with in-line assembly and you declare that function pascal,  you 
  189.     need to return the function’s value in a return statement outside the 
  190.     assembly block. Don’t put the return value into D0 yourself. For example, 
  191.     use this:
  192.     
  193.             pascal int foo (void)
  194.             {
  195.                 asm {
  196.                     . . .
  197.                 }
  198.                 return 1;
  199.              }
  200.         
  201.     instead of this:
  202.     
  203.             pascal int foo (void)
  204.             {
  205.                 asm {
  206.                     . . .
  207.                     move.w     #1, D0
  208.                 }
  209.              }
  210.  
  211.     Also note that you cannot return a value from an assembly block.
  212.     In an assembly block, you can use a return statement only if it does not 
  213.     return a value. For example, this code fragment causes an error: 
  214.     
  215.             pascal int foo (void)
  216.             {
  217.                 asm {
  218.                     . . .
  219.                     return 1    // NO! Cannot return a value from
  220.                 }                   // within an asm block
  221.              }    
  222.                  
  223. •  In THINK C 5.0, you need to write multi-line assembly language macros
  224.     differently than with earlier versions of THINK C. For example, this
  225.     multi-line macro causes an error in THINK C 5.0:
  226.  
  227.         #define LongMult(r, s1, s2) \
  228.             asm {  \
  229.                 move.w  s1, d0  \
  230.                 muls  s2, d0  \
  231.                 move.l  d0, r \
  232.             }
  233.  
  234.         void foo(void)
  235.         {
  236.             int a, b;
  237.             long d;
  238.  
  239.             LongMult(d, a, b)    // Syntax error
  240.             . . .
  241.         }
  242.  
  243.     Multi-line assembler macros cause errors because the THINK C 5.0
  244.     preprocessor expands the macro as one long line, like this:
  245.  
  246.         asm { move.w s1, d0  muls s2, do  move.l d0,r }
  247.  
  248.     The inline assembler doesn’t recognize the expansion as valid assembly
  249.     language. You can define the macro like this:
  250.  
  251.         #define LongMult(r, s1, s2) \
  252.             asm { move.w  s1, d0 } \
  253.             asm { muls  s2, d0  } \
  254.             asm { move.l  d0, r } 
  255.  
  256.     Or you can define LongMult as just the assembly language statements, 
  257.     without enclosing them in asm { . . . }, like this:
  258.  
  259.         #define LongMult(r, s1, s2) \
  260.             move.w  s1, d0  \
  261.             muls  s2, d0  \
  262.             move.l  d0, r 
  263.  
  264.     And then use the macro like this:
  265.  
  266.         void foo(void)
  267.         {
  268.             int a, b;
  269.             long d;
  270.  
  271.             asm {
  272.                 LongMult(d, a, b) 
  273.             }
  274.         . . .
  275.         }
  276.  
  277. •  On page 267, there’s an error in the section “C function entry.” It 
  278.     incorrectly states how THINK C handles a char-sized argument. The last 
  279.     two paragraphs in that section should read:
  280.     
  281.         All arguments occupy an even number of bytes on the stack.
  282.         If there is no prototype for a char-sized argument, it is placed 
  283.         in the low byte of an int, which may be 2 or 4 bytes, depending
  284.         on your option settings.
  285.         
  286.         If there is a prototype for a char-sized argument, it is placed
  287.         in the high byte of a short.
  288.  
  289. The Debugger
  290. ------------
  291. •  To stop the debugger from saving the current session, hold down the 
  292.     Option key as you exit the debugger.
  293.  
  294. •  To make the debugger display the source and data window in their
  295.     default positions, hold down the Shift key as you enter the debugger.
  296.  
  297. •  To stop the debugger from restoring saved breakpoints and data 
  298.     expressions hold down the Option key as you enter the debugger.
  299.     
  300. Standard Libraries Reference
  301. --------------------------
  302. •  On pages 208 and 209, the return value for the “isxxxx” family of 
  303.     functions (isalnum(), isalpha(), etc.) is wrong.  The second sentence in
  304.     the second paragraph should read:
  305.  
  306.         It returns non-zero if c is a member of the category,  and 
  307.         0 (zero) value if c isn’t.
  308.         
  309.     And the table in the section “Returns” should read:
  310.     
  311.         If c is…                           The function returns…
  312.         in the category               non-zero
  313.         not in the category         0 (zero)
  314.         
  315.         
  316. TECH TIPS
  317. =========
  318. THINK C has many new features and enhancements that help you improve
  319. your code.  Two changes in  THINK C 5.0 affect existing programs and 
  320. programs that you write in the future. The first change is that THINK C 5.0 
  321. conforms the ANSI standard. The second change is that THINK C now uses 
  322. the same Macintosh Toolbox interface files that Apple provides, and these 
  323. files contain more type-checking information than the built-in interfaces 
  324. in earlier versions of THINK C.
  325.  
  326. Though these changes in the THINK C development environment may mean 
  327. some changes to your existing programs, these programs will be easier to 
  328. maintain and more bug-free.
  329.  
  330. MacHeaders uses Apple’s interfaces
  331. --------------------------------
  332. The MacHeaders file that comes with THINK C 5.0 contains the interfaces for 
  333. the most common Macintosh Toolbox routines. This MacHeaders file is 
  334. precompiled with the "Check pointer types" option off, so all pointer types 
  335. in function prototypes are treated as generic pointers of type void *. If you 
  336. want stricter type checking for Macintosh Toolbox routines, follow the 
  337. instructions in Mac #includes.c to turn the stricter checking on.
  338.  
  339. Using stricter type-checking means that you need to cast parameters to 
  340. all Macintosh Toolbox routines, even the common ones like HLock() and 
  341. HUnlock(). The additional work pays off when THINK C catches an attempt to 
  342. pass a variable of the wrong type to a Toolbox routine.
  343.  
  344. Prototype Helper helps convert programs
  345. -------------------------------------
  346. The THINK C 5.0 package includes a tool called Prototype Helper to help you 
  347. convert your programs to the new ANSI standard. Prototype Helper creates 
  348. extra header files that contain the prototypes for all the functions in your 
  349. program files. Prototype Helper also converts old-style function definitions 
  350. to new-style ANSI function definitions. Many programmers report that 
  351. Prototype Helper helped them discover subtle problems that have hidden in 
  352. programs for months.
  353.  
  354. Prototype Helper uses a heuristic to convert your files, and may not always
  355. do what you expect. Since it alters your files in place, be sure to keep a
  356. backup of your files until you’re confident your converted files work 
  357. properly.
  358.  
  359. Function pointer types are more strictly enforced
  360. ---------------------------------------------
  361. THINK C 5.0 is much stricter about function pointer types than earlier 
  362. versions of THINK C.  In older versions, THINK C ignored the parameters to a 
  363. function pointer. For example, THINK C 4.0 treated both of these types 
  364. identically:
  365.  
  366.     typedef int (*SomeProcPtr)();
  367.     typedef int (*OtherProcPtr)(char);
  368.  
  369. THINK C 5.0 treats these two declarations as distinct types. It distinguishes 
  370. function pointer types by parameters as well as return value. THINK C 5.0 
  371. also allows the use of the keyword pascal as part of the function pointer 
  372. type. 
  373.  
  374. This change affects programs that use the type ProcPtr as a generic pointer. 
  375. For example, in THINK C 4.0, you could write this:
  376.  
  377.     ProcPtr fp;
  378.     (*fp)(1, 2L, 3);
  379.  
  380. In THINK C 5.0, this function pointer needs an explicit type. You can cast it 
  381. like this:
  382.  
  383.     ((void (*)(short, long, short)) fp) (1, 2L, 3);
  384.  
  385. Or, even better, you can define a type first:
  386.  
  387.     typedef void (*ShortLongShortFnPtr)(short, long, short);
  388.  
  389.     ShortLongShortFnPtr fp;
  390.  
  391.     fp(1, 2L, 3);
  392.     
  393. Note that the function pointer does not need to be dereferenced to perform 
  394. the call. The compiler does that for you.
  395.  
  396. short * and int * are not the same type
  397. -----------------------------------
  398. By default, the type short and the type int are the same size: 16 bits. 
  399. However, they are not the same type. The difference is particularly apparent 
  400. in functions that take pointers to shorts and pointers to int. For example:
  401.  
  402.     void f(short *p)
  403.     {
  404.        ...
  405.     }
  406.  
  407.     void g(void)
  408.     {
  409.        int j;
  410.  
  411.        f(&j);  // ERROR: types are incompatible
  412.        f((short *)&j);  // OK
  413.      }
  414.  
  415. Note that none of the Macintosh Toolbox routines take ints as parameters. 
  416. They take either shorts or longs.
  417.  
  418. _fp1() and _elems1() are internal SANE routines
  419. -------------------------------------------
  420. If you get an error message about a function called _fp1() or _elems1(), 
  421. don't panic. These are the compiler's name for the SANE routines that 
  422. implement the high-level SANE call on the highlighted line. You may get this 
  423. error if you're using SANE, and if you try and pass a variable of type double 
  424. to a SANE routine that expects an extended. For example, the sqrt() function 
  425. below expects its argument to be of type extended.
  426.  
  427.     #include <SANE.h>
  428.     ...
  429.     extended x;
  430.     x = sqrt((double) 123 / 4);
  431.  
  432. To see exactly how the _fp() function is called, use the Preprocess command 
  433. in the Source menu.
  434.  
  435. Even-sized arrays are now even-word aligned
  436. -----------------------------------------
  437. In some cases, THINK C 5.0 packs binary data differently than earlier 
  438. versions. If you have a structure that describes the format of binary data,  
  439. check whether the fields match up correctly in the new version. THINK C 5.0 
  440. aligns even-length arrays on even word boundaries and introduces a pad byte 
  441. if necessary. For example, in THINK C 4.0 this structure would be 12 bytes 
  442. long:
  443.  
  444.     struct foo {
  445.         char x;
  446.         char y[10];
  447.         char z;
  448.     };
  449.  
  450. The compiler would place the field y immediately after the field x. So y ends 
  451. up on an odd word boundary.
  452.  
  453. In THINK C 5.0, the same structure takes up 14 bytes. In order to align the 
  454. field y, the compiler places a pad byte between x and y. At this point, the 
  455. field z is placed at an odd address, making the structure's length 13 bytes. 
  456. Both THINK C 4.0 and THINK C 5.0 compilers will make sure that a structure 
  457. is an even length, so it is padded out with one more byte at the end.
  458.  
  459. To make sure that the structure is the same size in THINK C 5.0, make the 
  460. array odd-sized, and add the last element of the array as a field just after 
  461. the array. Since THINK C doesn't enforce array bounds checking, you can use 
  462. this declaration the same way as you used the previous one:
  463.  
  464.     struct foo {
  465.         char x;
  466.         char y[9];
  467.         char y10;     // introduce dummy name
  468.         char z;
  469.     };
  470.